import React, { Component } from 'react'
import Expo from 'expo'
import { StackNavigator } from 'react-navigation'
import { Root } from 'native-base'
import router from './router'
import routerConfig from './config/routerConfig'
import { ActivityIndicator } from 'antd-mobile'
import { connect } from 'dva-no-router'
import { contentFormat } from './utils/config'

let Router = StackNavigator(
    router, routerConfig
)

@connect(({ loading }) => ({ loading: loading.global && !loading.models.Verify }))
class App extends Component {
    async componentWillMount() {
        await Expo.Font.loadAsync({
            'Roboto': require('native-base/Fonts/Roboto.ttf'),
            'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
        })
    }
    render() {
        const { loading } = this.props
        return (
            <Root>
                <Router ref={nav => { GLOBAL.navigation = nav }} />
                <ActivityIndicator toast text="正在加载" animating={loading} />
            </Root>
        )
    }
}

export default App
